﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Ultima.Xna.Net.Packets
{
    public class ChangeCombatantPacket : RecvPacket
    {
        public ChangeCombatantPacket(PacketReader reader)
            : base(0xAA, "Change Combatant")
        {
            // TODO: Write this packet.
        }
    }

    public class CharacterListUpdatePacket : RecvPacket
    {
        public CharacterListUpdatePacket(PacketReader reader)
            : base(0x86, "Character List Update")
        {
            // TODO: Write this packet.
        }
    }

    public class CompressedGumpPacket : RecvPacket
    {
        public CompressedGumpPacket(PacketReader reader)
            : base(0xDD, "Compressed Gump")
        {
            // TODO: Write this packet.
        }
    }

    public class CorpseClothingPacket : RecvPacket
    {
        public CorpseClothingPacket(PacketReader reader)
            : base(0x89, "Corpse Clothing")
        {
            // TODO: Write this packet.
        }
    }

    public class DeathAnimationPacket : RecvPacket
    {
        public DeathAnimationPacket(PacketReader reader)
            : base(0xAF, "Death Animation")
        {
            // TODO: Write this packet.
        }
    }

    public class DisplayGumpFastPacket : RecvPacket
    {
        public DisplayGumpFastPacket(PacketReader reader)
            : base(0xB0, "Display Gump Fast")
        {
            // TODO: Write this packet.
        }
    }

    public class DisplayMenuPacket : RecvPacket
    {
        public DisplayMenuPacket(PacketReader reader)
            : base(0x7C, "Display Menu")
        {
            // TODO: Write this packet.
        }
    }

    public class Extended0x78Packet : RecvPacket
    {
        public Extended0x78Packet(PacketReader reader)
            : base(0xD3, "Extended 0x78")
        {
            // TODO: Write this packet.
        }
    }

    public class GlobalQueuePacket : RecvPacket
    {
        public GlobalQueuePacket(PacketReader reader)
            : base(0xCB, "Global Queue")
        {
            // TODO: Write this packet.
        }
    }

    public class GraphicEffectPacket : RecvPacket
    {
        public GraphicEffectPacket(PacketReader reader)
            : base(0x70, "Show Graphic Effect")
        {
            // TODO: Write this packet.
        }
    }

    public class HuedEffectPacket : RecvPacket
    {
        public HuedEffectPacket(PacketReader reader)
            : base(0xC0, "Hued Effect")
        {
            // TODO: Write this packet.
        }
    }

    public class InvalidMapEnablePacket : RecvPacket
    {
        public InvalidMapEnablePacket(PacketReader reader)
            : base(0xC6, "Invalid Map Enable")
        {
            // TODO: Write this packet.
        }
    }

    public class MessageLocalizedAffixPacket : RecvPacket
    {
        public MessageLocalizedAffixPacket(PacketReader reader)
            : base(0xCC, "Message Localized Affix")
        {
            // TODO: Write this packet.
        }
    }

    public class MessageLocalizedPacket : RecvPacket
    {
        public MessageLocalizedPacket(PacketReader reader)
            : base(0xC1, "Message Localized")
        {
            short packetLength = reader.ReadInt16();
            int id = reader.ReadInt32(); // 0xffff for system message
            int body = reader.ReadInt16(); // (0xff for system message
            int type = reader.ReadByte(); // 6 - lower left, 7 on player
            int hue = reader.ReadUInt16();
            int font = reader.ReadInt16();
            int messageNumber = reader.ReadInt32();
            string speakerName = reader.ReadString(30);
            // what about the arguments?
            // http://docs.polserver.com/packets/index.php?Packet=0xC1
        }
    }

    public class MobileAnimationPacket : RecvPacket
    {
        readonly Serial _serial;
        readonly short _action;
        readonly short _framecount;
        readonly short _repeatcount;
        readonly byte _reverse;
        readonly byte _repeat;
        readonly byte _delay;

        public Serial Serial
        {
            get { return _serial; }
        }

        public short Action
        {
            get { return _action; }
        }

        public short FrameCount
        {
            get { return _framecount; }
        }

        public short RepeatCount
        {
            get { return _repeatcount; }
        }

        public bool Reverse
        {
            get { return (_reverse == 1); }
        }

        public bool Repeat
        {
            get { return (_repeat == 1); }
        }

        public byte Delay
        {
            get { return _delay; }
        }

        public MobileAnimationPacket(PacketReader reader)
            : base(0x6E, "Mobile Animation")
        {
            _serial = reader.ReadInt32();
            _action = reader.ReadInt16();
            _framecount = reader.ReadInt16();
            _repeatcount = reader.ReadInt16();
            _reverse = reader.ReadByte(); // 0x00=forward, 0x01=backwards
            _repeat = reader.ReadByte(); // 0 - Don't repeat / 1 repeat
            _delay = reader.ReadByte();
        }
    }

    public class ObjectHelpResponsePacket : RecvPacket
    {
        public ObjectHelpResponsePacket(PacketReader reader)
            : base(0xB7, "Display Menu")
        {
            // TODO: Write this packet.
        }
    }

    public class OpenPaperdollPacket : RecvPacket
    {
        public OpenPaperdollPacket(PacketReader reader)
            : base(0x88, "Open Paperdoll")
        {
            // TODO: Write this packet.
        }
    }

    public class OpenWebBrowserPacket : RecvPacket
    {
        public OpenWebBrowserPacket(PacketReader reader)
            : base(0xA5, "Open Web Browser")
        {
            // TODO: Write this packet.
        }
    }

    public class ParticleEffectPacket : RecvPacket
    {
        public ParticleEffectPacket(PacketReader reader)
            : base(0xC7, "Particle Effect")
        {
            // TODO: Write this packet.
        }
    }

    public class PlayMusicPacket : RecvPacket
    {
        public PlayMusicPacket(PacketReader reader)
            : base(0x6D, "Play Music")
        {
            // TODO: Write this packet.
        }
    }

    public class PlaySoundEffectPacket : RecvPacket
    {
        public PlaySoundEffectPacket(PacketReader reader)
            : base(0x54, "Play Sound Effect")
        {
            // TODO: Write this packet.
        }
    }

    public class QuestArrowPacket : RecvPacket
    {
        public QuestArrowPacket(PacketReader reader)
            : base(0xBA, "Quest Arrow")
        {
            // TODO: Write this packet.
        }
    }

    public class ResurrectionMenuPacket : RecvPacket
    {
        public ResurrectionMenuPacket(PacketReader reader)
            : base(0x2C, "Resurrection Menu")
        {
            // TODO: Write this packet.
        }
    }

    public class SendSkillsPacket : RecvPacket
    {
        public SendSkillsPacket(PacketReader reader)
            : base(0x3A, "Send Skills List")
        {
            // TODO: Write this packet.
        }
    }

    public class TimePacket : RecvPacket
    {
        public TimePacket(PacketReader reader)
            : base(0x5B, "Time")
        {
            // TODO: Write this packet.
        }
    }

    public class TipNoticePacket : RecvPacket
    {
        public TipNoticePacket(PacketReader reader)
            : base(0xA6, "Tip Notice")
        {
            // TODO: Write this packet.
        }
    }

    public class VendorSellListPacket : RecvPacket
    {
        public VendorSellListPacket(PacketReader reader)
            : base(0x9E, "Vendor Sell List")
        {
            // TODO: Write this packet.
        }
    }
}
